//
//  HYBaseNavController.swift
//  weibo-01
//
//  Created by 源 何 on 16/9/22.
//  Copyright © 2016年 何源. All rights reserved.
//

import UIKit

class HYBaseNavController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        
    }

    //重写push方法
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        
        //一旦空实现了这个方法.导航视图控制器无法设置根视图控制器
        let count = childViewControllers.count
        
        if count > 0 {
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", imageName: "navigationbar_back_withtext", target: self, action: #selector(back))
            
            //当进入子视图的时候 隐藏底部tabbar
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc private func back() {
        self.popViewController(animated: true)
    }

}
